package repository

import (
	"github.com/lab-online/internal/class/entity"
	"github.com/lab-online/internal/class/infra/model"
	"gorm.io/gorm"
)

func (r *Repository) DeleteClass(classEntity entity.ClassEntity) error {
	class := model.New(model.WithID(classEntity.GetID()))
	if err := r.db.Session(&gorm.Session{FullSaveAssociations: true}).
		Delete(class).Error; err != nil {
		errorHandler(err)
	}
	return nil
}
